﻿<%@ codepage=65001%><% 'UTF-8%><% '用户管理%>
<!--#include file="../Include/Common.All.asp"-->
<!--#include file="../Include/Conn.asp"-->
<% call OpenConn%>

<!--#include file="../Include/Common.Security.asp"-->
<!--#include file="../Include/MD5.asp"-->
<!--#include file="../Include/JSON_2.0.2.asp"-->
<!--#include file="../Include/JSON_UTIL_0.1.1.asp"-->



<%

	'定义json对象
	Dim jsonObj,jsonObj_user
	Set jsonObj = jsObject()
	Set jsonObj_user = jsObject()
	UserID=ReplaceBadChar(Trim(Session("UserID")))
	
	dim act 
  act=request("act")
 	Dim rsObj,strSql
	 	''定义查询字段变量
 	dim id,UserID,UserPassword,	UserName,TrueName,	oldpwd,newpwd,repwd 


 	
	''查询信息列表
	if "edit"=act then
 			jsonObj("msg") = "操作失败，请重试..."
			jsonObj("success") = 0'"false"

''修改信息

			UserID=ReplaceBadChar(Trim(request.Form("UserID")))
			oldpwd=ReplaceBadChar(Trim(request.Form("oldpwd")))
			newpwd=ReplaceBadChar(Trim(request.Form("newpwd")))
			repwd=ReplaceBadChar(Trim(request.Form("repwd")))
			
			 
			'MD5处理密
			oldpwd = MD5(oldpwd, 16)
			newpwd = MD5(newpwd, 16)
			repwd = MD5(repwd, 16) 
      
			''Dim rsObj,strSql
			set rsObj=Server.CreateObject("ADODB.Recordset")
			strSql = "Select  * from PE_User where UserID='"&UserID&"' "
			''Response.Write strSql&"-----"
			rsObj.Open strSql, Conn, 1, 3
			If rsObj.BOF And rsObj.EOF Then 
				jsonObj("msg") = "用户不存在，操作失败，请重试..." 
				jsonObj("success") = 0'"false"
			else	
				if (newpwd<>repwd) then 
					jsonObj("msg") = "两次密码输入不一致，操作失败，请重试..." 
					jsonObj("success") = 0'"false"
				elseif (oldpwd<>rsObj("UserPassword")) then							
					jsonObj("msg") = "原密码输入不正确，操作失败，请重试..." 
					jsonObj("success") = 0'"false"
				else							
					rsObj("UserPassword") = newpwd
					rsObj.Update
					jsonObj("msg") = "添加成功，正在跳转..."
					jsonObj("success") = 1'"success"
					jsonObj("url") = "secure.asp"
				end if		
			 
	 		end if	
			rsObj.close
			Set rsObj = Nothing

	end If''' 
 

	'输出json对象
	jsonObj.Flush
	''Response.Write strSql&"-----"
 '释放数据库链接
	call CloseConn

''{
''    rslist : [ { name: "mac", desc: "computer",     
''                   price: 1000, quantity: 100, alert:null },
''                 { name: "ipod", desc: "music player", 
''                   price:  200, quantity: 200, alert:"on sale now!" },
''                 { name: "cinema display", desc: "screen",       
''                   price:  800, quantity: 300, alert:"best deal!" } ],
''    customer : { first: "John", last: "Public", level: "gold" }
''}

%>